package com.effectiv.gooruda.rest.docs.pojo;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;


import org.springframework.data.annotation.Id;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import com.effectiv.gooruda.rest.docs.annotation.Api;

@ToString
public class ApiDoc implements Comparable<ApiDoc> {
	@Id
	@Getter @Setter
	private String jsondocId  = UUID.randomUUID().toString();
	@Getter @Setter
	private String name;
	
	@Getter @Setter
	private String description;
	@Getter @Setter
	private String version;
	
	@Getter @Setter
	private String basePath;
	
	@Getter @Setter
	private List<ApiMethodDoc> methods;

	public static ApiDoc buildFromAnnotation(Api api) {
		ApiDoc apiDoc = new ApiDoc();
		apiDoc.setDescription(api.description());
		apiDoc.setName(api.name());
		return apiDoc;
	}

	public ApiDoc() {
		this.methods = new ArrayList<ApiMethodDoc>();
	}

	
	public void addMethod(ApiMethodDoc apiMethod) {
		this.methods.add(apiMethod);
	}

	
	public int compareTo(ApiDoc o) {
		return name.compareTo(o.getName());
	}

}
